package homework.day03;

import java.io.*;

public class Test03 {
    public static void main(String[] args) throws IOException {

        File dir = new File("./src/main/java/io");
        File[] subs = dir.listFiles(f -> f.getName().endsWith(".java"));
        String line;
        for (int i = 0; i < subs.length; i++) {
            File sub = subs[i];
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(
                            new FileInputStream(sub)
                    )
            );
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }

        }

    }

}
/*
    提示代码:
	需要用到的语句，尝试按照正确顺序将下列代码并放在main方法中完成需求，
	并在注释中标注每句话的作用，

    //遍历每一个java文件
    for(int i=0;i<subs.length;i++){

    }
    //读取内容不为null走循环
    while((line = br.readLine())!=null){

    }

    //声明一个File类型数组sub
    File sub = subs[i];

    //new一个缓冲字符输入流br
    BufferedReader br = new BufferedReader(
           new InputStreamReader(
                  new FileInputStream(sub)
           )
    );

    //获取当前项目目录下src/io目录
    File dir = new File("./src/main/java/io");

    //输出line
    System.out.println(line);

    //声明一个String型变量line
    String line;

    //获取该目录下的所有.java文件
    File[] subs = dir.listFiles(f->f.getName().endsWith(".java"));
 */